﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lotour.IBrand;
using Lucene.Net.Index;
using Lucene.Net.Documents;
using Lotour.BrandIndex;
using Lotour.BrandEntity;

namespace Lotour.BrandIndex
{
   public class AirHotLineDetailCreate:CreateBrand
    {

        protected override void Indexrecord(object obj, IndexWriter writer)
        {
            AirHotLineDetailModel m = obj as AirHotLineDetailModel;
            Document doc = new Document();
            doc.Add(new Field("ID", m.ID.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("StartCityCode", m.StartCityCode, Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("StartCityName", m.StartCityName, Field.Store.YES, Field.Index.NO));
            doc.Add(new Field("EndCityCode", m.EndCityCode, Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("EndCityName", m.EndCityName, Field.Store.YES, Field.Index.NO));
            doc.Add(new Field("AirLineCode", m.AirLineCode, Field.Store.YES, Field.Index.NO));
            doc.Add(new Field("EntId", m.EntId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("EntPercentSale", m.EntPercentSale.ToString(), Field.Store.YES, Field.Index.NO));
            doc.Add(new Field("EntPrice", m.EntPrice.ToString(), Field.Store.YES, Field.Index.NO));
            doc.Add(new Field("LowPrice", m.LowPrice.ToString(), Field.Store.YES, Field.Index.NO));
            doc.Add(new Field("PercentSale", m.PercentSale.ToString(), Field.Store.YES, Field.Index.NO));
            doc.Add(new Field("TravelDate", m.TravelDate.ToString("yyyy-MM-dd"), Field.Store.YES, Field.Index.NO));
            if (m.StartCityCode.ToLower() == "pek" && m.EndCityCode.ToLower() == "sha")
            {
                Console.WriteLine(m.StartCityCode + "" + m.EndCityCode);
            }
            writer.AddDocument(doc);
        }

        public override void Create()
        {
            List<AirHotLineDetailModel> list = AirHotLineDetailData.Instance.GetAirHotLineDetail();
            Init(list);
        }
    }
}
